//
//  NSString+Addtions.m
//  iphone.jymobileoa
//
//  Created by Pill Gong on 13-11-11.
//  Copyright (c) 2013年 Epoint. All rights reserved.
//

#import "NSString+Addtions.h"
#import "EpointConsts.h"

@implementation NSString (Addtions)

+ (CGFloat)getSingleLineHeight {
    return [self getSingleLineHeight:[UIFont systemFontOfSize:17]];
}

+ (CGFloat)getSingleLineHeight:(UIFont *)font {
    CGSize textSize = [@"123" sizeWithFont:font constrainedToSize:CGSizeMake(AppWidth, MAXFLOAT) lineBreakMode:0];
    return textSize.height;
}

- (CGFloat)getTextHeight {
    return [self getTextHeightWithFont:[UIFont systemFontOfSize:17] withSuperViewWidth:AppWidth];
}

- (CGFloat)getTextHeightWithFont:(UIFont *)font withSuperViewWidth:(CGFloat)superViewWidth {
    CGSize textSize = [self sizeWithFont:font constrainedToSize:CGSizeMake(superViewWidth, MAXFLOAT) lineBreakMode:0];
    return textSize.height;
}


+ (CGFloat)getMailDetailSingleLineHeight {
    return [self getSingleLineHeight:[UIFont boldSystemFontOfSize:18.0]];
}

- (CGFloat)getMailDetailTitleHeight {
    return [self getTextHeightWithFont:[UIFont boldSystemFontOfSize:18.0] withSuperViewWidth:AppWidth-20];
}

+ (NSString *)filterHTML:(NSString *)html
{
    NSScanner * scanner = [NSScanner scannerWithString:html];
    NSString * text = nil;
    while([scanner isAtEnd]==NO)
    {
        //找到标签的起始位置
        [scanner scanUpToString:@"<" intoString:nil];
        //找到标签的结束位置
        [scanner scanUpToString:@">" intoString:&text];
        //替换字符
        html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>",text] withString:@""];
    }
    //    NSString * regEx = @"<([^>]*)>";
    //    html = [html stringByReplacingOccurrencesOfString:regEx withString:@""];
    return html;
}

+ (NSString *)stringInt:(int)num {
    return [NSString stringWithFormat:@"%d", num];
}

@end
